//
//  SetUpTableViewCell.m
//  WhereToTravel
//
//  Created by dlios on 15/10/17.
//  Copyright © 2015年 zhoushengmin. All rights reserved.
//

#import "SetUpTableViewCell.h"

#define W self.contentView.frame.size.width
#define H self.contentView.frame.size.height

@implementation SetUpTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"night" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(night) name:@"night" object:nil];
    }
    return self;
}

- (void)createView {
    [super createView];
    self.titleLabel.font = [UIFont boldSystemFontOfSize:22];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.titleLabel.frame = CGRectMake(0, 0, W, H);
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.equalTo(self.contentView);        
    }];
}

- (void)night {
    if ([SingletonNight shareSingletonNight].isSelete == YES) {
        self.titleLabel.textColor = [UIColor whiteColor];
    }
    else {
        self.titleLabel.textColor = [UIColor blackColor];
    }
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
}

@end
